<?php

namespace app\index\controller;

use app\common\controller\Frontend;

class Index extends Frontend
{

    protected $noNeedLogin = '*';
    protected $noNeedRight = '*';
    protected $layout = '';

    public function index()
    {
        return json(['code' => 0, 'msg' => 'error1']);
        return $this->view->fetch();
    }


    /**
     * Notes: 删除账号
     * User: chenLei
     * Date: 8/25/25
     * @return string
     * @throws \think\Exception
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function del_user()
    {

        if ($this->request->isPost()) {
            $account = input('account');
            if (empty($account)) {
                $this->error('Please enter the account');
            }

            $user = \app\common\model\User::where('username', $account)->where('status', 'normal')->find();
            if (empty($user)) {
                $this->error('No valid user found');
            }

            $user->status = 'hidden';
            $user->save();

            $this->success('Deletion successful');
        }


        return $this->view->fetch();
    }
}
